package com.taysear.dbservice.resources;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateTimeX
{
	/**
	 * Generates DateTime in a string format
	 * 
	 * @return string
	 */
	public enum FORMATS { NOW, STRING };
	public static java.sql.Date getTimeStamp()
	{
		Calendar cal = Calendar.getInstance();
		return new java.sql.Date(cal.getTimeInMillis());
	}
	public static String getDateTimeStr(FORMATS pType)
	{
		//final String NOW = "yyyy-MM-dd HH:mm:ss";
		//final String STRING = "yyyyMMddhhmmssSSS";
		 
		DateFormat df=null;
		if(pType==FORMATS.NOW)
		{
			df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		}
		else if(pType==FORMATS.STRING)
		{
			df = new SimpleDateFormat("yyyyMMddhhmmssSSS");	
		}
		
		Date today = Calendar.getInstance().getTime();  
		String reportDateTime = df.format(today);		 
		return reportDateTime;
	}
}
